﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Text;
using System.Security.Cryptography;

namespace Royaume
{
    public class cUtility
    {

        public static void fnMsgBox(string sMessage, Page myPage)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("alert('");
            sb.Append(sMessage.Replace("\n", "\\n").Replace("\r", "").Replace("'", "\\'"));
            sb.Append("');");
            ScriptManager.RegisterStartupScript(myPage, myPage.GetType(), "showalert", sb.ToString(), true);
        }

        public static void fnMsgBox(string sMessage, Page myPage, System.Web.UI.Page instance)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("alert('");
            sb.Append(sMessage.Replace("\n", "\\n").Replace("\r", "").Replace("'", "\\'"));
            sb.Append("');");
            ScriptManager.RegisterStartupScript(myPage, instance.GetType(), "showalert", sb.ToString(), true);
        }

        public static string Encrypt(string mot)
        {
            MD5CryptoServiceProvider objMd5 = new MD5CryptoServiceProvider();
            string result = "";
            byte[] data = Encoding.ASCII.GetBytes(mot);

            data = objMd5.ComputeHash(data);
            result = Encoding.ASCII.GetString(data);
            return result;
        }

       

    }
}